package com.cpos.bkge.controller;/*
*  @创建人 Cpos_wl
*  @创建时间 2020/8/10
   @描述
*/

import com.cpos.bkge.base.ResultInfo;
import com.cpos.bkge.entity.CposBkUser;
import com.cpos.bkge.utils.CodeUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

@RestController
@RequestMapping("/bkge/common")
public class CposCommonController {

    @Value("${cpos.upload.codeUrl}")
    private String codeUrl;


    //生成验证码
    @RequestMapping(value = "/code",method = RequestMethod.POST)
    @ResponseBody
    @CrossOrigin
    public ResultInfo code(HttpServletRequest request,HttpServletResponse response){
        ResultInfo resultInfo  = new ResultInfo();
        Map<String, Object> code = CodeUtils.code();
        String code1 = (String) code.get("code");
        request.getSession().setAttribute("code",code1);

        code.put("codeImage",codeUrl);

        resultInfo.setData(code);
        return resultInfo;
    }

    //校验验证码
    @RequestMapping(value = "/checkCode",method = RequestMethod.POST)
    @ResponseBody
    @CrossOrigin
    public ResultInfo checkCode(HttpServletRequest request,HttpServletResponse response){
        return null;
    }
}
